import request from '@/utils/request';

/**
 * 分页查询用户
 */
export async function get_list(params) {
  const res = await request.post('/jewelry/receipts_group/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area
    };
  }
  return Promise.reject(res.data.msg);
}

/* 库存统计 */
export async function get_goods_list(params) {
  const res = await request.post('/jewelry/goods_info/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area
    };
  }
  return Promise.reject(res.data.msg);
}

/* 出入柜详情 */
export async function receipts_purchase_detail(params) {
  const res = await request.post('/jewelry/receipts_group/detail', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}

/* 作废出入柜单据 */
export async function cancel_purchase(params) {
  const res = await request.post(
    '/jewelry/receipts_group/cancel_group',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 删除出入柜单据 */
export async function del_receipts(params) {
  const res = await request.post(
    '/jewelry/receipts_group/del_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 反审出入柜单据 */
export async function back_verify(params) {
  const res = await request.post('/jewelry/receipts_group/back_verify', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 取消审核出入柜单据 */
export async function cancel_verify(params) {
  const res = await request.post(
    '/jewelry/receipts_group/cancel_verify',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 提交审核出入柜单据 */
export async function confirm_purchase(params) {
  const res = await request.post(
    '/jewelry/receipts_group/confirm_group',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}

/* 添加货品 */
export async function add_goods(params) {
  const res = await request.post('/jewelry/receipts_group/add_goods', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 删除货品 */
export async function del_goods(params) {
  const res = await request.post('/jewelry/receipts_group/del_goods', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
